def getprimes(limit):
	primes = set()
	nums = range(2,limit+1)
	marked = [0] * limit
	p = 2
	for p in nums:
		if not marked[p-2]:
			n = 2
			a = p*n
			while(a <= limit):
				marked[a-2] = 1
				n = n + 1
				a = p*n
	for x in range(limit-1):
		if not marked[x]:
			primes.add(nums[x])
	return primes

primes = getprimes(999999)

x = 9

while True:
    if x in primes:
        pass
    else:
        yes = 0
#        print(x)
        tests = [y for y in primes if y < x]
        for n in tests:
            s = 0
            while 2*(s**2) < (x - n):
                s = s + 1
            if (n + 2*(s**2)) == x:
#                print(str(x)+" = "+str(n)+" + 2 x "+str(s)+"^2")
                yes = 1
                break
        if yes == 0:
            print(x)
            break
    x = x + 2